//////////////////////////////////////////////////////////////////////////////////
//	 Copyright 2011 by Yosef Grabivker, ryuho@homenetworksoft.com
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//////////////////////////////////////////////////////////////////////////////////

#ifndef _PERS_LIST_YG_H__
#define _PERS_LIST_YG_H__

#include "def.h"
#include "logctrl.h"
#include <wx/dnd.h>



class CPersistenList: public wxPanel
{
public:
								CPersistenList(class wxWindow* pParent, cMACBlockRuleId id );
	virtual						~CPersistenList(void);

	void						SetController(class CListPairController*	pController) { m_pController = pController; }
	MACBLOCK					GetData()	{ return m_block; }
	void						SetData(const MACBLOCK& block);

	MACLIST						RemoveExisted(const MACLIST&	list) const;
	void						RemoveItems(const MACLIST& list);
	void						AddItems(const MACLIST& list);
	bool						ExistInList(const MACENTRY& entry);
	bool						IsExistedInPair( const MACLIST&	list );
	bool						IsOwnPCListed( const MACLIST&	list );
	bool						CanAddItems( const MACLIST&	list );
	bool						CanAcceptItems( const MACLIST&	list );

	void						RemoveAll();

	void						OnContextMenu(long id, long col) {}

	//List Control
	long						GetItemCount(wxWindowID id=wxID_ANY)
	{
		return m_block.list.size();
	}

	wxString					GetItemText(long item, long column, wxWindowID id=wxID_ANY);

	int							GetItemColumnImage(long item, long column, wxWindowID id=wxID_ANY)
	{
		return -1;
	}

	virtual int					GetItemImage(long item, wxWindowID id=wxID_ANY)
	{
		return -1;
	}

	class wxListItemAttr*		GetItemAttr(long item, wxWindowID id=wxID_ANY)
	{
		return NULL;
	}

	bool						OnDropText(wxCoord x, wxCoord y, const wxString& data);
	void						OnDragDropFinished( wxWindowID id, wxDragResult result);

protected:
	void						OnAdd(wxCommandEvent& ev);
	void						OnEdit(wxCommandEvent& ev);
	void						OnEditUpdateUI(wxUpdateUIEvent& event);
	void						OnRemove(wxCommandEvent& ev);
	void						OnRemoveUpdateUI(wxUpdateUIEvent& event);
	void						OnBlockOthersUpdateUI(wxUpdateUIEvent& event);
	void						OnBlockAll(wxCommandEvent& ev);

	DECLARE_EVENT_TABLE()

private:
	

private:
	class wxListCtrl*			m_pList;
	class wxButton*				m_pAddButtom;		
	class wxButton*				m_pRemoveButtom;
	class wxCheckBox*			m_pBlockOthers;
	class CListPairController*	m_pController;

	MACBLOCK					m_block;
};

#endif //_PERS_LIST_YG_H__